import request from '@/utils/request'

export function getPage(data) {
  return request({
    url: `/crop/page?keyword=${data.keyword}&page=${data.page}&limit=${data.limit}`,
    method: 'get' // query
  })
}

export function getListUrl(data){
  return request({
      url:`/crop/listWithUrl?cropName=${data.cropName}`,
      method:'get',
  })
}

export function addCrop(data){ 
  return request({
    url: `/crop/save`,
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data: data // body
  })
}

export function updateCrop(data) {
  return request({
    url: `/crop/update`,
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data: data
  })
}

export function deleteCrop(data) {
  return request({
    url: `/crop/delete/${data.cropId}`,
    method: 'post'
  })
}

export function deleteCrops(data) {
  return request({
    url: `/crop/deleteList?ids%5B%5D=${data.item}`,
    method: 'post'
  })
}

export function getListwithUrl(query) { // 查询植物列表，实训管理部分带图片的列表,无分页
  return request({
    url: '/crop/listWithUrl',
    method: 'get',
    params:query
  })
}

export function getCropParams(query) { // 查询作物中的所有参数
  return request({
    url: '/cropParameter/page',
    method: 'get',
    params: query
  })
}

export function getCropProperty(data) { // 查询作物参数：属性中的属性
  return request({
    url: `/cropProperty/list/${data.cropId}`,
    method: 'get'
  })
}

export function getCropGrowthPeriod(data) { // 获得作物生育期的属性
  return request({
    url: `/cropGrowthPeriod/list/${data.cropId}`,
    method: 'get'
  })
}

export function addData(data) {
  return request({
    url: '/dataReport/save',
    method: 'post',
    data
  })
}
